import requests
import re
import time

def phone_get(phoneNum):
    endTime = int(time.time()) * 1000
    url = f"http://139.199.224.115:9016/smsgateway/smsService/getSmsReport?phoneNum={phoneNum}&lastId=19073750&startTime=1618419183000&endTime={endTime}"
    header1 = {"authToken": "A897EE539B5C3221A73B768E63989DD28BCCEF36BFC67B79EB8FFCACA21B8245E2F481DCA78C6D209138119903D2FBE3"}
    res = requests.get(url,headers=header1)
    # print(res.json())
    lis = []

    for ele in range(0, len(res.json())):
        try:
            res_str = res.json()[ele].get("smsContent")
            ver_code = re.search(r"(\d{4})", res_str)
            ver_code = ver_code.group()
            lis.append(ver_code)
        except:
            pass

    if len(lis) == 0:
        lis.append("没有验证码")
    return lis




if __name__ == '__main__':
    print(phone_get(18602755812))
